package com.study.lihan.proxy.jdk;

import com.study.lihan.proxy.UserInterface;
import com.study.lihan.proxy.UserService;

import java.lang.reflect.Proxy;

/**
 * @Author: lihan
 * @Date : 2021/12/31- 12
 * @DESCRIPTION: com.study.lihan.proxy.jdk
 * @version: 1.0
 */
public class TestJdkNoPublic {
    public static void main(String[] args) {
        System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles","true");
        NoPublicUserService userService = new NoPublicUserService();
        MyInvocationHandlerNopublic invocationHandler = new MyInvocationHandlerNopublic(userService);
        NoPublicInterface instance =(NoPublicInterface) Proxy.newProxyInstance(NoPublicUserService.class.getClassLoader(),
                                                                        new Class[]{NoPublicInterface.class},
                                                                            invocationHandler);
        instance.ask();
    }
}
